package com.gegao.practise.simple;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.DynamicDrawableSpan;
import android.text.style.ImageSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gegao.practise.R;

public class TestToast extends Activity {
    Button mBt;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.one_button);
        mBt = (Button)findViewById(R.id.bt);
        
        mBt.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v) {
                showTip();
            }
        });
        
        
    }
    
    private void showTip(){
        
        View mTip = LayoutInflater.from(this).inflate(R.layout.tip_gesture_prev_back, null);
        
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT);
        
        FrameLayout frameLayout = (FrameLayout) getWindow()
                .getDecorView().findViewById(android.R.id.content);
        frameLayout.addView(mTip,params);
        
        TextView mSelectArticle = (TextView) mTip.findViewById(R.id.gesture_tip);
        
        
        mSelectArticle.setText(R.string.gesture_back_tip);
        mSelectArticle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.gesture_backward, 0, 0, 0);
        
        
        
        
        
//        final String lightStr = getString(R.string.light_seperator);
//        Drawable d = getResources().getDrawable(R.drawable.gesture_backward);
//        d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
//        ImageSpan span = new ImageSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM);
//        SpannableString ss = new SpannableString(getString(
//                R.string.gesture_back_tip, lightStr));
//        int start = ss.toString().indexOf(lightStr);
//        ss.setSpan(span, start, start + lightStr.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
//        mSelectArticle.setBackgroundResource(R.drawable.tip_back);
//        mSelectArticle.setText(ss);
    }

}
